<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>新增商品</title>
    <link rel="stylesheet" href="__PEAR__/component/pear/css/pear.css" />
    <style>
    #tabbox{display:none;}
    </style>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox" id="tabbox">
        <div class="main-container">
            <div class="main-container">
            
	            <div class="layui-tab">
				  <ul class="layui-tab-title">
				    <li class="layui-this">基本信息</li>
				    <li>辅助属性</li>
				    <li>其他价格</li>
				  </ul>
				  <div class="layui-tab-content">
				    <div class="layui-tab-item layui-show">
				    	{include file="product/add_basic" /}
				    </div>
				    <div class="layui-tab-item">
				    	{include file="product/add_access" /}
				    </div>
				    <div class="layui-tab-item">
				    	{include file="product/add_price" /}
				    </div>
				  </div>
				</div>
			
                 <p style="color:#ff6a08;text-align:center;"> * 添加商品信息后可以再点击"编辑"上传图片、添加供应商价格等信息</p>
                 
        		<input name="id" type="hidden" value="{$one['id']}"/>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="item-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__PEAR__/component/pear/pear.js"></script>
<script>
layui.use(['form','jquery'],function(){
    let form = layui.form;
    let $ = layui.jquery;
    var path="/{$MODULE_NAME}/Product";
	var _url="/addPost";
	//加载完成显示所有标签页
	$("#tabbox").show();

    form.on('submit(item-save)', function(data){
        $.ajax({
            url:path+_url,
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.code){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("items-table");
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>